package com.yitong.Estshopping.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.SelectBeforeUpdate;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * Model class of image.
 * 
 * @author generated by ERMaster
 * @version $Id$
 */
@Table(name="pinglun")
@Entity
@SelectBeforeUpdate
public class Pinglun implements Serializable {

	/** serialVersionUID. */
	private static final long serialVersionUID = 1L;

	/** plid. */
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="plid")
	private Integer plid;

	/** 评论内容. */
	@Column(name="pltext",columnDefinition="text")
	private String pltext;
	/** 时间 */
	@Column(name="pldate")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")  
	public Date pdate;

	/** 评论状态. */
	@Column(name="state")
	private Integer state;
	/** 匿名. */
	@Column(name="isni")
	private String isni;
	
	/** 点赞数量*/
	@Column(name="zan")
	private Integer zan;
	/**
	 * 追评
	 */
	@JoinColumn(name = "zid")
	@ManyToOne
	@JsonIgnore
	private Pinglun pinglun;
	
	@JoinColumn(name = "uid")
	@ManyToOne
	@JsonIgnore
	private User user;
	@JoinColumn(name = "pid")
	@ManyToOne
	@JsonIgnore
	private Product product;
	public Integer getPlid() {
		return plid;
	}
	public void setPlid(Integer plid) {
		this.plid = plid;
	}
	public String getPltext() {
		return pltext;
	}
	public void setPltext(String pltext) {
		this.pltext = pltext;
	}
	public Date getPdate() {
		return pdate;
	}
	public void setPdate(Date pdate) {
		this.pdate = pdate;
	}
	public Integer getState() {
		return state;
	}
	public void setState(Integer state) {
		this.state = state;
	}
	public String getIsni() {
		return isni;
	}
	public void setIsni(String isni) {
		this.isni = isni;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public Product getProduct() {
		return product;
	}
	public void setProduct(Product product) {
		this.product = product;
	}
	
	public Integer getZan() {
		return zan;
	}
	public void setZan(Integer zan) {
		this.zan = zan;
	}
	public Pinglun getPinglun() {
		return pinglun;
	}
	public void setPinglun(Pinglun pinglun) {
		this.pinglun = pinglun;
	}
	public Pinglun() {
		super();
		// TODO Auto-generated constructor stub
	}
	/**
	 * 评论
	 * @param pltext
	 * @param state
	 * @param isni
	 * @param user
	 * @param product
	 */
	public Pinglun(String pltext, Integer state, String isni, User user, Product product) {
		super();
		this.pltext = pltext;
		this.pdate = new Date();
		this.state = state;
		this.isni = isni;
		this.user = user;
		this.product = product;
		this.zan = 0;
	}
	/**
	 * 追评
	 * @param pltext
	 * @param state
	 * @param isni
	 * @param zan
	 * @param pinglun
	 * @param user
	 * @param product
	 */
	public Pinglun(String pltext, Integer state, String isni,Pinglun pinglun, User user,
			Product product) {
		super();
		this.pltext = pltext;
		this.pdate = new Date();
		this.state = state;
		this.isni = isni;
		this.zan = 0;
		this.pinglun = pinglun;
		this.user = user;
		this.product = product;
	}
	
}
